/*
 *    Copyright 2022 jacky4631 shen ji email:121659050@qq.com
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.dataoke.shoppingguide.app773026.waimai;

import static com.dataoke.shoppingguide.app773026.bean.Constants.MEITUAN_SUPERMARKET_URL;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.Window;
import android.widget.ImageView;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.dataoke.shoppingguide.app773026.R;
import com.dataoke.shoppingguide.app773026.util.AppUtil;
import com.dataoke.shoppingguide.app773026.util.GlideUtils;

/**
 * 用户协议
 * @author: shen ji
 * @date: 2022/4/4
 * @email: 121659050@qq.com
 * @wechat: jacky4631
 */

public class ImageActivity extends AppCompatActivity {

    private static final String TAG = ImageActivity.class.getSimpleName();

    private ImageView ivImage;

    public static void show(Context context) {
        Intent intent = new Intent(context, ImageActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();

        window.setStatusBarColor(getResources().getColor(R.color.price));
        setContentView(R.layout.activity_image);

        initView();
    }

    private void initView() {
        Toolbar mToolBar = (Toolbar) findViewById(R.id.toolbar);
        if (mToolBar != null) {
            setSupportActionBar(mToolBar);
            ActionBar actionBar = getSupportActionBar();
            if (actionBar != null) {
                actionBar.setDisplayHomeAsUpEnabled(true);
                actionBar.setHomeButtonEnabled(true);
            }
        }
        ivImage = findViewById(R.id.iv_image);

        ivImage.setOnClickListener(v -> {
            AppUtil.openWxMeituan(ImageActivity.this, MEITUAN_SUPERMARKET_URL);
        });
        GlideUtils.loadWaimaiImgCrop(this, getString(R.string.meituan_waimai_img_url), ivImage);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        if(item.getItemId()==android.R.id.home){
            finish();
        }

        return super.onOptionsItemSelected(item);
    }
}
